package cn.itsource.factory;

import cn.itsource.admin.dto.RuleDto;
import cn.itsource.api.RuleFeignClient;
import cn.itsource.result.JSONResult;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class RuleFeignClientFactory implements FallbackFactory<RuleFeignClient> {

    @Override
    public RuleFeignClient create(Throwable cause) {
        return new RuleFeignClient() {
            @Override
            public JSONResult valuation(String mileage) {
                return JSONResult.error(cause.getMessage());
            }

            @Override
            public JSONResult getRuleDto(int hours) {
                return JSONResult.error(cause.getMessage());
            }

            @Override
            public JSONResult getDriverTotalProportion() {
                return JSONResult.error(cause.getMessage());
            }
        };
    }
}
